<template>
    <el-drawer
        v-model="isShow"
        size="50%"
        :destroy-on-close="true"
        @close="closeHandle"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        :show-close="false"
    >
        <template #header="{ titleId, titleClass }">
            <h4 :id="titleId" :class="titleClass">选择111卷宗</h4>
        </template>
        <el-form ref="queryParamsRef" label-width="90px" :inline="true" :model="queryParams">
            <el-row :gutter="20" style="width: 100%">
                <el-col :span="9">
                    <el-form-item label="部门受案号" style="width: 100%">
                        <el-input v-model="queryParams.casecode" clearable @clear="getTableDataLists"/>
                    </el-form-item>
                </el-col>
                <el-col :span="9">
                    <el-form-item label="案件名称" style="width: 100%">
                        <el-input v-model="queryParams.name" 
                        clearable 
                        @clear="getTableDataLists" 
                        @keyup.enter.prevent="getTableDataLists"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-button type="primary" @click="getTableDataLists">
                        <el-icon class="me-1">
                            <Search/>
                        </el-icon>
                        查询
                    </el-button>
                    <el-button @click="handleRest">
                        <el-icon class="me-1">
                            <Refresh/>
                        </el-icon>
                        重置
                    </el-button>
                </el-col>
            </el-row>
        </el-form>
        <el-divider class="mt-0 mb-3"/>
        <el-table
            v-loading="loading"
            :data="TablesData"
            show-overflow-tooltip
            @selection-change="handleSelectionChange"
        >
            <el-table-column type="selection" width="55" />
            <el-table-column label="部门受案号" prop="casecode"/>
            <el-table-column label="案件名称" prop="name"/>
            <el-table-column label="赃证物类别" prop="casecode"/>
            <el-table-column label="承办人" prop="peoplename"/>
            <el-table-column label="添加时间" prop="casetype"/>
            <el-table-column label="状态" prop="state" width="80">
                <template #default="scope">
                    <dict-tag :options="nj_anjian_status" :value="scope.row.state"/>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-show="total > 0"
            :total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="getTableDataLists"
        />
        <template #footer>
            <el-button type="primary" @click="queren">确认</el-button>
            <el-button  @click="isShow = false">关11闭</el-button>
        </template>
    </el-drawer>
</template>
<script setup>
const {proxy} = getCurrentInstance();
// import {getCaseInfoList,getCaseInfoInfo,  deleteCaseInfo} from "@/api/CaseInfo/CaseInfo";
import PageEnum from "@/enum/PageEnum.js";

const {nj_anjian_type,nj_anjian_status} = proxy.useDict('nj_anjian_type', 'nj_anjian_status')

const isShow = ref(false)
const loading = ref(false)

const rowvalue = ref()
const queryParams = ref({
    name: '',
    casecode: '',
    // 页码
    pageNum: 1,
    // 分页数量
    pageSize: PageEnum.SIZE
})

const total = ref(0)
const TablesData = ref([
    {name:'111',peoplename:"张三"},
    {name:'222',peoplename:"李四"},
    {name:'333',peoplename:"王五"},
])
const BatchList = ref([])
// 通知事件
const emit = defineEmits(['getList'])

const changeShowStatus = () => {
    isShow.value = !isShow.value
}
onMounted(() => {
    // getTableDataLists()
})
const showCaseList = () => {
    changeShowStatus()
}
defineExpose({showCaseList})

// 获取案件列表
const getTableDataLists = async () => {
    // loading.value = true
    // await getCaseInfoList(proxy.addDateRange(queryParams.value)).then(res => {
    //     loading.value = false;
    //     TablesData.value = res.rows
    //     total.value = res.total;
    // });
}
// 批量选中
const handleSelectionChange = async (val) => {
    console.log(val)
    BatchList.value = val.map(item => item.name);  
}
const queren = () => {
    console.log(BatchList.value)
    // proxy.$modal.msgSuccess("选择了数据");
    // rowvalue.value--后面应该调用新增借阅 接口，成功后执行下面两个方法
    // emit('getList')
    // changeShowStatus()
}
// 重置搜索调解
const handleRest = () => {
    queryParams.value = {
        name: '',
        casecode: '',
    }
    getTableDataLists()
}
// 关闭后的回调事件
const closeHandle = () => {
    queryParams.value = {
        
    }
}
</script>

<style lang="scss" scoped>

</style>